/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.db.generator;

import net.db.generator.field.models.BaseFieldModel;
import net.db.generator.utils.ClassGeneratorUtil;

/**
 *
 * @author Aleksandar
 */
public class JavaBasePKClassWriter extends JavaBaseClassWriter{
    
    public static String PK_POSTFIX = "PK";
    
    public JavaBasePKClassWriter() {
        super();
    }
    
    protected void generateConstructor(){
        
        super.generateConstructor();
        
        String params = "";
        String sets = "";
        for (BaseFieldModel fieldModel : fields) {
            String field = fieldModel.getFieldName();
            String type = fieldModel.getFieldType();
            params += type + " " + field + ", "; 
            sets += spaces + spaces + "this." + field + " = " + field + ";\n";
        }
        
        params = params.substring(0, params.length() -2);
        
        stringClass.append(spaces).append("public ").append(ClassGeneratorUtil.humanize(getClassName())).append("(" + params + ")").append("{\n");
        stringClass.append(sets);
        stringClass.append(spaces).append("}\n\n");
    }
    
    @Override
    protected void generateClassName() {
        stringClass.append("public class ").append(ClassGeneratorUtil.humanize(getClassName())).append(" extends BasePK {\n\n");
    }

    @Override
    public String getClassName() {
        return super.getClassName() + PK_POSTFIX;
    }
    
}
